package com.xnfh.mine.ui.activity

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import com.huantansheng.easyphotos.utils.permission.PermissionUtil
import com.lxj.xpopup.XPopup
import com.xnfh.framework.base.BaseActivity
import com.xnfh.framework.toast.TipsToast
import com.xnfh.framework.utils.PermissionUtils
import com.xnfh.mine.R
import com.xnfh.mine.databinding.ActivityFeedbackLayoutBinding

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/12/19 15:53
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/19 15:53
 * @UpdateRemark: 更新说明
 */
class FeedbackActivity : BaseActivity<ActivityFeedbackLayoutBinding>(), View.OnClickListener {
    override fun getLayoutID(): Int = R.layout.activity_feedback_layout
    companion object{
        private const val PHONE_CODE = "tel:010-62899099"
        fun start(context: Context){
            val intent = Intent(context, FeedbackActivity::class.java)
            context.startActivity(intent)
        }
    }


    override fun init(savedInstanceState: Bundle?) {
        setHeaderTitle(getString(com.xnfh.framework.R.string.str_feedback))
        mBind.feedbackCallPhone.setOnClickListener(this)
    }

    override fun observe() {
    }

    override fun onClick(v: View?) {
        when (v) {
            mBind.feedbackCallPhone -> {
                XPopup.Builder(this).asConfirm(getString(com.xnfh.framework.R.string.str_tips),getString(R.string.call_phone_tips)){
                    PermissionUtils.requestCallPhonePermission(this@FeedbackActivity,object :PermissionUtils.PermissionImp{
                        override fun onSuccess(allGranted: Boolean) {
                            val intent = Intent(Intent.ACTION_DIAL, Uri.parse(PHONE_CODE))
                            intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
                            startActivity(intent)
                        }
                    })
                }.show()
            }
        }
    }
}